/**
 * 
 */
package com.globalresources.dao.hibernate;

import java.util.List;

import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

import com.globalresources.dao.inface.IHospitalDao;
import com.globalresources.po.Hospital;

/**
 * @author Administrator
 *
 */
public class HospitalDaoHibernate  extends HibernateDaoSupport implements IHospitalDao{

	/* (non-Javadoc)
	 * @see com.globalresources.dao.inface.IHospitalDao#deleteHospital(com.globalresources.po.Hospital)
	 */
	public boolean deleteHospital(Hospital hospital) {
		// TODO Auto-generated method stub
		try{
		 getHibernateTemplate().delete(hospital);
		 return true;
		}catch(Exception e){
			e.printStackTrace();
			return false;
		}
	}

	/* (non-Javadoc)
	 * @see com.globalresources.dao.inface.IHospitalDao#findBySql(java.lang.String)
	 */
	public List<Hospital> findBySql(String sql) {
		// TODO Auto-generated method stub
		return getHibernateTemplate().find(sql);
	}

	/* (non-Javadoc)
	 * @see com.globalresources.dao.inface.IHospitalDao#saveHospital(com.globalresources.po.Hospital)
	 */
	public boolean saveHospital(Hospital hospital) {
		// TODO Auto-generated method stub
		try{
			 getHibernateTemplate().save(hospital);
			 return true;
			}catch(Exception e){
				e.printStackTrace();
				return false;
			}
	}

	/* (non-Javadoc)
	 * @see com.globalresources.dao.inface.IHospitalDao#saveOrUpdateHospital(com.globalresources.po.Hospital)
	 */
	public boolean saveOrUpdateHospital(Hospital hospital) {
		// TODO Auto-generated method stub
		try{
			 getHibernateTemplate().saveOrUpdate(hospital);
			 return true;
			}catch(Exception e){
				e.printStackTrace();
				return false;
			}
	}
	
	public List<Hospital> findAll(){
		return getHibernateTemplate().find("from Hospital hospital order by hospital.id desc");
	}
	
	
}
